<template>
	<div class="mobile">
		<div class="nav-top">
			<div class="left">
				<router-link to="/portal/netm"><img src="../../../assets/img/phone-back.png" alt=""></router-link>
			</div>
			<div class="right">
				<span>民情动态</span>
				<img src="../../../assets/img/phone-more.png" alt="">
			</div>

		</div>
		<div class="trends-form">
			<div class="form-detail">
				<div class="input1">
					<span>*</span>
					<b>标题</b>
					<input type="text" placeholder="请输入标题" v-model="title">
				</div>
				<div class="input2">
					<div class="name">
						<span>*</span><b>内容</b>
						<div class="num">{{content.length}}/2000</div>
					</div>
					<editor v-model="content" placeholder="请输入内容" :min-height="300"/>
				</div>
				<div class="sub-title">
					<div class="cont">
						<div class="line"></div>
						<span><b>相关材料</b></span>
						<span prop="attachmentUrl"></span>

					</div>
					<file-upload v-model="attachmentUrl" />
				</div>
				<div class="sub-title">
					<div class="cont">
						<div class="line"></div><b>联系对象</b>
					</div>
				</div>
				<div class="slect-group bob">
					<div class="gruop active" v-if="userInfo.role == '1'">
						人大街工委
					</div>
					<div class="gruop active" v-if="userInfo.role == '2'">
						人大代表
					</div>
				</div>
				<div class="slect-group">
					<div class="tit">选择具体联系人<div class="btn">
							<select v-model="selected">
								<option v-bind:value="item.id" v-for="item in userList">{{ item.name }}</option>
							</select>
						</div>
					</div>
				</div>
				<div class="confirm-btn" @click="confirm()">
					提交
				</div>
			</div>

		</div>
		<div class="trends-nav">
			<div class="item active"><img src="../../../assets/img/phone-icon2.png" alt="">新建动态</div>
			<div class="item"><router-link :to="{ path: '/portal/net/trendsm' }"><img
						src="../../../assets/img/phone-icon1.png" alt="">历史记录</router-link></div>
		</div>
	</div>
</template>

<script>
import { getTrendsUserList, addTrends } from "@/api/website";
export default {
	data() {
		return {
			selected:'',
			userInfo: "",
			currentUser: {},
			userList: [],
			title: "",
			content: "",
			attachmentUrl: null,
		}
	},
	components: {

	},
	created() {
		this.userInfo = JSON.parse(sessionStorage.getItem("useInfo"))
		this.getData();
	},
	mounted() {

	},
	methods: {
		getData() {
			getTrendsUserList({ parentId: this.userInfo.parentId, role: this.userInfo.role }).then(response => {
				this.currentUser = response[0];
				this.selected =   response[0].id;
				this.userList = response;
			});
		},
		confirm() {
			if (!this.title) {
				this.$modal.msgError("请输入标题");
				return
			}
			if (!this.content) {
				this.$modal.msgError("请输入服务内容");
				return
			}
			debugger
			addTrends({
				"voterId": this.currentUser.id,
				"voterName": this.currentUser.name,
				"contactInfo": this.currentUser.contactInfo,
				"constituencyId": this.currentUser.id,
				"representativeId": this.currentUser.id,
				"title": this.title,
				"material": this.attachmentUrl,
				"content": this.content,
				"feedbackTime": new Date(),
				"contactPersonId": this.currentUser.id
			}).then(response => {
				this.$router.push('/portal/net/trendsm');
			});
		}
	}

};
</script>

<style scoped lang="scss"></style>